package com.haotunet.app.goldtreasure.adapter;

import java.util.List;
import com.haotunet.app.goldtreasure.R;
import com.haotunet.app.goldtreasure.activity.PickGoldDetailActivity;
import com.haotunet.app.goldtreasure.model.ExtractRecord;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class PickRecordAdapter extends HolderAdapter<ExtractRecord, PickRecordAdapter.ViewHolder> {

	public PickRecordAdapter(Context context, List<ExtractRecord> mlist) {
		super(context, mlist);
	}

	public static class ViewHolder {
		TextView tvGoldBrand;
		TextView tvPickQuantity;
		TextView tvStoreAddress;
		TextView tvOrderNO;
		TextView tvTradeStatus;
		TextView tvPickTime;
	}

	@Override
	public View buildConvertView(LayoutInflater layoutInflater, ExtractRecord t, int position) {
		return inflate(R.layout.item_pick_record);
	}

	@Override
	public ViewHolder buildHolder(View convertView, ExtractRecord t, int position) {
		ViewHolder holder = new ViewHolder();
		holder.tvPickQuantity = (TextView) convertView.findViewById(R.id.txt_pick_quantity);
		holder.tvPickTime = (TextView) convertView.findViewById(R.id.pick_time);
		holder.tvGoldBrand = (TextView) convertView.findViewById(R.id.txt_gold_brand);
		holder.tvOrderNO = (TextView) convertView.findViewById(R.id.pick_order_no);
		holder.tvStoreAddress = (TextView) convertView.findViewById(R.id.txt_store_address);
		holder.tvTradeStatus = (TextView) convertView.findViewById(R.id.txt_trade_status);
		return holder;
	}

	@Override
	public void bindViewDatas(View convertView, ViewHolder holder, ExtractRecord extractRecord, int position) {
		final String orderNo = extractRecord.getOrderNo();
		holder.tvPickQuantity.setText(extractRecord.getGoldQuantity());
		holder.tvPickTime.setText(extractRecord.getCreateTime());
		holder.tvOrderNO.setText(orderNo);
		holder.tvGoldBrand.setText(extractRecord.getGoldType());
		holder.tvStoreAddress.setText(extractRecord.getShopName());
		holder.tvTradeStatus.setText(extractRecord.getStatusText());
		convertView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context, PickGoldDetailActivity.class);
				intent.putExtra("order_no", orderNo);
				context.startActivity(intent);
			}
		});
	}

}
